
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>文件和目录访问 &#8212; Python 3.7.3 文档</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/translations.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="在 Python 3.7.3 文档 中搜索"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="关于这些文档" href="../about.html" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="copyright" title="版权所有" href="../copyright.html" />
    <link rel="next" title="pathlib --- 面向对象的文件系统路径" href="pathlib.html" />
    <link rel="prev" title="operator --- 标准运算符替代函数" href="operator.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/library/filesys.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    <script type="text/javascript" src="../_static/switchers.js"></script>
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="pathlib.html" title="pathlib --- 面向对象的文件系统路径"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="operator.html" title="operator --- 标准运算符替代函数"
             accesskey="P">上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <span class="language_switcher_placeholder">zh_CN</span>
          <span class="version_switcher_placeholder">3.7.3</span>
          <a href="../index.html">文档</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python 标准库</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="file-and-directory-access">
<span id="filesys"></span><h1>文件和目录访问<a class="headerlink" href="#file-and-directory-access" title="永久链接至标题">¶</a></h1>
<p>本章中描述的模块处理磁盘文件和目录。 例如，有一些模块用于读取文件的属性，以可移植的方式操作路径以及创建临时文件。 本章的完整模块列表如下：</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pathlib.html"><code class="docutils literal notranslate"><span class="pre">pathlib</span></code> --- 面向对象的文件系统路径</a><ul>
<li class="toctree-l2"><a class="reference internal" href="pathlib.html#basic-use">基础使用</a></li>
<li class="toctree-l2"><a class="reference internal" href="pathlib.html#pure-paths">纯路径</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pathlib.html#general-properties">通用性质</a></li>
<li class="toctree-l3"><a class="reference internal" href="pathlib.html#operators">运算符</a></li>
<li class="toctree-l3"><a class="reference internal" href="pathlib.html#accessing-individual-parts">访问个别部分</a></li>
<li class="toctree-l3"><a class="reference internal" href="pathlib.html#methods-and-properties">方法和特征属性</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pathlib.html#concrete-paths">具体路径</a><ul>
<li class="toctree-l3"><a class="reference internal" href="pathlib.html#methods">方法</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="pathlib.html#correspondence-to-tools-in-the-os-module">对应的 <code class="docutils literal notranslate"><span class="pre">os</span></code> 模块的工具</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="os.path.html"><code class="docutils literal notranslate"><span class="pre">os.path</span></code> --- 常见路径操作</a></li>
<li class="toctree-l1"><a class="reference internal" href="fileinput.html"><code class="docutils literal notranslate"><span class="pre">fileinput</span></code> --- Iterate over lines from multiple input streams</a></li>
<li class="toctree-l1"><a class="reference internal" href="stat.html"><code class="docutils literal notranslate"><span class="pre">stat</span></code> --- Interpreting <code class="docutils literal notranslate"><span class="pre">stat()</span></code> results</a></li>
<li class="toctree-l1"><a class="reference internal" href="filecmp.html"><code class="docutils literal notranslate"><span class="pre">filecmp</span></code> --- File and Directory Comparisons</a><ul>
<li class="toctree-l2"><a class="reference internal" href="filecmp.html#the-dircmp-class">The <code class="docutils literal notranslate"><span class="pre">dircmp</span></code> class</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="tempfile.html"><code class="docutils literal notranslate"><span class="pre">tempfile</span></code> --- Generate temporary files and directories</a><ul>
<li class="toctree-l2"><a class="reference internal" href="tempfile.html#examples">示例</a></li>
<li class="toctree-l2"><a class="reference internal" href="tempfile.html#deprecated-functions-and-variables">Deprecated functions and variables</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="glob.html"><code class="docutils literal notranslate"><span class="pre">glob</span></code> --- Unix style pathname pattern expansion</a></li>
<li class="toctree-l1"><a class="reference internal" href="fnmatch.html"><code class="docutils literal notranslate"><span class="pre">fnmatch</span></code> --- Unix filename pattern matching</a></li>
<li class="toctree-l1"><a class="reference internal" href="linecache.html"><code class="docutils literal notranslate"><span class="pre">linecache</span></code> --- Random access to text lines</a></li>
<li class="toctree-l1"><a class="reference internal" href="shutil.html"><code class="docutils literal notranslate"><span class="pre">shutil</span></code> --- High-level file operations</a><ul>
<li class="toctree-l2"><a class="reference internal" href="shutil.html#directory-and-files-operations">Directory and files operations</a><ul>
<li class="toctree-l3"><a class="reference internal" href="shutil.html#copytree-example">copytree example</a></li>
<li class="toctree-l3"><a class="reference internal" href="shutil.html#rmtree-example">rmtree example</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="shutil.html#archiving-operations">Archiving operations</a><ul>
<li class="toctree-l3"><a class="reference internal" href="shutil.html#archiving-example">Archiving example</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="shutil.html#querying-the-size-of-the-output-terminal">Querying the size of the output terminal</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="macpath.html"><code class="docutils literal notranslate"><span class="pre">macpath</span></code> --- Mac OS 9 路径操作函数</a></li>
</ul>
</div>
<div class="admonition seealso">
<p class="first admonition-title">参见</p>
<dl class="last docutils">
<dt>模块 <a class="reference internal" href="os.html#module-os" title="os: Miscellaneous operating system interfaces."><code class="xref py py-mod docutils literal notranslate"><span class="pre">os</span></code></a></dt>
<dd>操作系统接口，包括处理比 Python <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">文件对象</span></a> 更低级别文件的功能。</dd>
<dt>模块 <a class="reference internal" href="io.html#module-io" title="io: Core tools for working with streams."><code class="xref py py-mod docutils literal notranslate"><span class="pre">io</span></code></a></dt>
<dd>Python的内置 I/O 库，包括抽象类和一些具体的类，如文件 I/O 。</dd>
<dt>内置函数 <a class="reference internal" href="functions.html#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a></dt>
<dd>使用 Python 打开文件进行读写的标准方法。</dd>
</dl>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>上一个主题</h4>
  <p class="topless"><a href="operator.html"
                        title="上一章"><code class="docutils literal notranslate"><span class="pre">operator</span></code> --- 标准运算符替代函数</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="pathlib.html"
                        title="下一章"><code class="docutils literal notranslate"><span class="pre">pathlib</span></code> --- 面向对象的文件系统路径</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">提交 Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/library/filesys.rst"
            rel="nofollow">显示源代码
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="pathlib.html" title="pathlib --- 面向对象的文件系统路径"
             >下一页</a> |</li>
        <li class="right" >
          <a href="operator.html" title="operator --- 标准运算符替代函数"
             >上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <span class="language_switcher_placeholder">zh_CN</span>
          <span class="version_switcher_placeholder">3.7.3</span>
          <a href="../index.html">文档</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">版权所有</a> 2001-2019, Python Software Foundation.
    <br />
    Python 软件基金会是一个非盈利组织。
    <a href="https://www.python.org/psf/donations/">请捐助。</a>
    <br />
    最后更新于 4月 09, 2019.
    <a href="../bugs.html">发现了问题</a>？
    <br />
    使用<a href="http://sphinx.pocoo.org/">Sphinx</a>1.8.4 创建。
    </div>

  </body>
</html>